package com.cinyi.cyds.base.mongo;

import java.util.List;

import com.mongodb.DBCursor;
import com.mongodb.DBObject;

public interface IMongoService {
	public boolean isDocumentExsit(String collectionName, DBObject query);
	public DBObject selectDocument(String collectionName, DBObject query) ;
	public List<DBObject> selectDocuments(String collectionName, DBObject query);
	public List<DBObject> selectDocuments(String collectionName, DBObject query,int skip,int limit) ;
	public DBCursor selectDocumentsInCursor(String collectionName, DBObject query,int skip,int limit) ;
	
	public void insertDocument(String collectionName, DBObject newDocument) ;
	public void insertDocuments(String collectionName, List<DBObject> documents) ;
	public boolean updateDocument(String collectionName, DBObject query, DBObject updatedDocument) ;
	/**
	 * 如果存在该记录，则更新，否则插入
	 * @param collectionName
	 * @param query
	 * @param updatedDocument
	 * @param upSert			是否插入，默认false
	 * @return
	 */
	public boolean updateOrSaveDocument(String collectionName, DBObject query, DBObject updatedDocument , boolean upSert) ;
	public boolean deleteDocument(String collectionName, DBObject query) ;
	
	
}
